home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
7_10.lha
/
7_10
/
p_waitvec.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
921b
|
42 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <process.h>
include <debug.h> /* DELETE */
/ pause until one of the objects listed
/ in the vector becomes available.
nt process::wait(process_object **wv)
if (debug) /*DELETE*/ cerr << "process" << this << "::wait(vec)\n";
if (mustrecurse())
return wait(wv);
else
{
t_desiredtime = 0;
for (;;)
{
// look for object not pending
for (int i = 0; wv[i] != 0; i++)
{
if (!wv[i]->pending())
{
// tell everyone to forget us
for (int j = 0; wv[j] != 0; j++)
wv[j]->forget(this);
if (debug) /*DELETE*/ cerr << "<<<< process" << this << "::wait(vec) <- " << i << "\n";
return i;
}
wv[i]->remember(this);
}
if ((i == 0) && (wv[0] == (process_object*)this))
error("trying to wait for self");
pause();
}
}